home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-serious-
/
programming
/
other
/
gui4cli
/
tools
/
rtn
/
viewfile
< prev
Wrap
Text File
|
1999-05-14
|
4KB
|
165 lines
G4C
; ViewFile FileName FileType Mode
; FileName = the File Name
; FileType = the File Type, as returned from the GetFileType routine
; Mode = (optional) CLI or RUN (RUN is default)
; ======================================================================
xONLOAD filename filetype mode
; load the 8SVX player
; ifexists assign guis:
; ifexists file guis:ext/gcsound/gcsound
; run 'guis:ext/gcsound/gcsound'
; endif
; endif
guiopen viewfile $filename $filetype $mode
xONQUIT
; ifexists port gcsound ; quit 8svx player
; call gcsound quit
; endif
xONRELOAD filename filetype mode
guiopen viewfile $filename $filetype $mode
xONOPEN filename filetype mode
if $filename = ''
or $filetype = ''
return
endif
docase $filetype
; ----- do special cases first.
case = TEXT ; a text file (probably)
GuiLoad guis:tools/read.gc $viewfile/filename
return
break
case = INFO ; icons
if $filename[-1][1] = \" ; remove the .info extention
cutvar filename cut char -6 ''
appvar filename \"
else
cutvar filename cut char -5 ''
endif
guiload guis:tools/icon.gc $viewfile/filename
return
break
case = G4C ; Yes.. you guessed it.
GuiLoad $filename
return
break
case = LHA ; LhA - all these are CLI'ied
cli '$*DEF.LHA x $filename ram:'
return
break
case = LZX ; LZX
cli 'LZX x $filename ram:'
return
break
case = ZIP ; unzip - it blocks the shell - why ???
cli 'run >nil: <nil: $*DEF.UNZIP $filename -d ram:'
return
break
case = EXE ; A program ? - Use cli.gc to run it.
GuiLoad guis:tools/cli.gc $viewfile/filename RUN
return
break
case = UNKNOWN
; gui to deal with it..
guiopen ViewFile2
return
break
case = 8SVX ; try internal player *NO*
; ifexists port gcsound
; call gcsound sound $filename 1 ; play it once
; else
filetype = SMPL ; otherwise use def player
; endif
; return
endcase
; If we got this far, then it's one of the simple types such as
; GIF or ILBM etc - We just contruct & issue the command to run it.
com = '\$*DEF.$filetype' ; construct command name
if $mode == CLI
CLI '$com $filename'
else
RUN '$com $filename'
endif
; routine ends here.
xOnQuit
guiquit ViewFile2
; ######################################################################
NEWFILE Viewfile2 ; last chance gui
; ######################################################################
WinBig 0 0 80 90 ""
WinType 00001000
winonmouse 40 10
varpath viewfile ; merge variables with the above file
xOnRMB
guiclose ViewFile2
xOnInactive
guiclose ViewFile2
xOnFail
ezreq "Error during operation" OK ""
;---------------> the Buttons
xbutton 0 0 0 15 MView
guiclose ViewFile2
run 'multiview $filename screen'
xbutton 0 15 0 15 List
GuiLoad guis:tools/read.gc $viewfile/filename
xbutton 0 30 0 15 Play16
guiclose ViewFile2
run '$*DEF.SMPL $filename'
xbutton 0 45 0 15 Run
guiclose ViewFile2
run '$filename'
xbutton 0 60 0 15 With..
guiclose ViewFile2
prog = ''
ReqFile -1 -1 300 220 'Run file with..' LOAD prog hd1:Players
if $prog > ''
run '$prog $filename'
endif
xbutton 0 75 0 15 'CliGui'
guiclose ViewFile2
setvar cl_Main '$filename '
GuiLoad guis:tools/cli.gc $viewfile/filename CLI
setgad cli.gc 1 ON